#include<cstdio>//uncle-lu
#include<cstring>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int n, c;
int line[60], sum[60];
int F[60][60][2];

int main()
{
	read(n);read(c);
	for (int i = 1; i <= n; i++) 
	{
		read(line[i]);read(sum[i]);
		sum[i] += sum[i-1];
	}

	memset(F, 0x7f7f7f, sizeof(F));
	F[c][c][1] = F[c][c][0] = 0;

	for (int len = 2; len <= n; len++) 
		for (int l = 1; l <= n - len + 1; l++) 
		{
			int r = l + len - 1;
			F[l][r][0] = std::min(F[l+1][r][0] + (line[l+1]-line[l])*(sum[n]-sum[r]+sum[l]), F[l+1][r][1] + (line[r]-line[l])*(sum[n]-sum[r]+sum[l]));
			F[l][r][1] = std::min(F[l][r-1][1] + (line[r]-line[r-1])*(sum[n]-sum[r-1]+sum[l-1]), F[l][r-1][0]+(line[r]-line[l])*(sum[n]-sum[r-1]+sum[l-1]));
		}

	printf("%d", std::min(F[1][n][1], F[1][n][0]));
	return 0;
}
